<?php

class KtController extends Controller
{

	/**
	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	 * using two-column layout. See 'protected/views/layouts/column2.php'.
	 */
	public $layout='//layouts/main';

	public function actionIndex()
	{
		$this->pageTitle = Lang::getResource("kt.title");
		$criteria = new CDbCriteria;
		$criteria->limit = 10;
		$criteria->order = 'position DESC, createdDate DESC';
		$techs=Tech::model()->findAll($criteria);

		$dataProvider = new CArrayDataProvider($techs, array(
				'id'=>'id',
				'sort'=>array(
						'attributes'=>array(
								'createdDate', 'title'
						),
				),
				'pagination'=>array(
						'pageSize'=>5,
				),
		));

		$this->render('index',array(
				'dataProvider'=>$dataProvider,
		));
	}

	public function actionDetail($id)
	{
		
		$criteria = new CDbCriteria;
		$criteria->select='*';
		$criteria->condition='id = :id';
		$criteria->params=array(':id'=> $id);
		$tech=Tech::model()->find($criteria);
		$this->pageTitle = $tech->title;
		$this->pageDesc = $tech->desc;
		$this->render('detail',array(
				'data'=>$tech,
		));
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
	// return the filter configuration for this controller, e.g.:
	return array(
			'inlineFilterName',
			array(
					'class'=>'path.to.FilterClass',
					'propertyName'=>'propertyValue',
			),
	);
	}

	public function actions()
	{
	// return external action classes, e.g.:
	return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
					'class'=>'path.to.AnotherActionClass',
					'propertyName'=>'propertyValue',
			),
	);
	}
	*/
}